Socket
Socket
Sign inDemoInstall

axios-cookiejar-support

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cookiejar-support

Add tough-cookie support to axios.


Version published
Weekly downloads
273K
increased by0.9%
Maintainers
1
Weekly downloads
 
Created

What is axios-cookiejar-support?

The axios-cookiejar-support package is an extension for the popular Axios HTTP client that adds support for handling cookies using a cookie jar. This is particularly useful for maintaining session state across multiple HTTP requests.

What are axios-cookiejar-support's main functionalities?

Setting up a cookie jar

This feature allows you to set up a cookie jar that can be used to store and manage cookies across multiple HTTP requests. The code sample demonstrates how to create a cookie jar using the tough-cookie library and wrap an Axios instance with it.

const axios = require('axios');
const { wrapper } = require('axios-cookiejar-support');
const { CookieJar } = require('tough-cookie');

const jar = new CookieJar();
const client = wrapper(axios.create({ jar }));

Making requests with cookie jar support

Once the Axios instance is wrapped with the cookie jar, you can make HTTP requests as usual, and the cookies will be automatically managed. The code sample shows a simple GET request to an example URL.

client.get('https://example.com')
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });

Persisting cookies across requests

This feature demonstrates how cookies are persisted across multiple requests. The code sample shows a login request followed by a request to a dashboard, with the cookies from the login request being used in the subsequent request.

client.get('https://example.com/login')
  .then(response => {
    return client.get('https://example.com/dashboard');
  })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });

Other packages similar to axios-cookiejar-support

Keywords

FAQs

Package last updated on 24 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc